package com.example.mylibrary.data;

import com.example.mylibrary.greendao.DaoSession;
import com.example.mylibrary.greendao.ItemDao;
import com.example.mylibrary.greendao.StudentInfoDao;
import com.example.mylibrary.greendao.StudentItemDao;

import org.greenrobot.greendao.DaoException;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.NotNull;
import org.greenrobot.greendao.annotation.ToOne;

/**
 * Created by Administrator on 2017/12/11.
 * 学生项目表
 */
@Entity
public class StudentItem {
    //学生项目ID
   @Id(autoincrement = true)
   private Long studentItemID;

    //学生id
    private long studentID;
    @ToOne(joinProperty = "studentID")
    private StudentInfo studentInfo;

    //项目id
    private long itemID;
    @ToOne(joinProperty = "itemID")
    private Item itemid;

    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;

    /** Used for active entity operations. */
    @Generated(hash = 2115443769)
    private transient StudentItemDao myDao;
    @Generated(hash = 1385040620)
    public StudentItem(Long studentItemID, long studentID, long itemID) {
        this.studentItemID = studentItemID;
        this.studentID = studentID;
        this.itemID = itemID;
    }
    @Generated(hash = 383807586)
    public StudentItem() {
    }
    public Long getStudentItemID() {
        return this.studentItemID;
    }
    public void setStudentItemID(Long studentItemID) {
        this.studentItemID = studentItemID;
    }
    public long getStudentID() {
        return this.studentID;
    }
    public void setStudentID(long studentID) {
        this.studentID = studentID;
    }
    public long getItemID() {
        return this.itemID;
    }
    public void setItemID(long itemID) {
        this.itemID = itemID;
    }
    @Generated(hash = 2140021173)
    private transient Long studentInfo__resolvedKey;
    /** To-one relationship, resolved on first access. */
    @Generated(hash = 1165871653)
    public StudentInfo getStudentInfo() {
        long __key = this.studentID;
        if (studentInfo__resolvedKey == null
                || !studentInfo__resolvedKey.equals(__key)) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            StudentInfoDao targetDao = daoSession.getStudentInfoDao();
            StudentInfo studentInfoNew = targetDao.load(__key);
            synchronized (this) {
                studentInfo = studentInfoNew;
                studentInfo__resolvedKey = __key;
            }
        }
        return studentInfo;
    }
    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 135847639)
    public void setStudentInfo(@NotNull StudentInfo studentInfo) {
        if (studentInfo == null) {
            throw new DaoException(
                    "To-one property 'studentID' has not-null constraint; cannot set to-one to null");
        }
        synchronized (this) {
            this.studentInfo = studentInfo;
            studentID = studentInfo.getStudentID();
            studentInfo__resolvedKey = studentID;
        }
    }
    @Generated(hash = 1993510474)
    private transient Long itemid__resolvedKey;
    /** To-one relationship, resolved on first access. */
    @Generated(hash = 628937880)
    public Item getItemid() {
        long __key = this.itemID;
        if (itemid__resolvedKey == null || !itemid__resolvedKey.equals(__key)) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            ItemDao targetDao = daoSession.getItemDao();
            Item itemidNew = targetDao.load(__key);
            synchronized (this) {
                itemid = itemidNew;
                itemid__resolvedKey = __key;
            }
        }
        return itemid;
    }
    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 495097744)
    public void setItemid(@NotNull Item itemid) {
        if (itemid == null) {
            throw new DaoException(
                    "To-one property 'itemID' has not-null constraint; cannot set to-one to null");
        }
        synchronized (this) {
            this.itemid = itemid;
            itemID = itemid.getItemID();
            itemid__resolvedKey = itemID;
        }
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }
    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 829923681)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getStudentItemDao() : null;
    }

}
